package com.team7.happycommunity.personcentor.service.impl;

import com.team7.happycommunity.personcentor.dao.CommunityDynamicCommentDao;
import com.team7.happycommunity.personcentor.entity.CommunityDynamicComment;
import com.team7.happycommunity.personcentor.service.CommunityDynamicCommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CommunityDynamicComment)表服务实现类
 *
 * @author makejava
 * @since 2020-03-24 17:26:32
 */
@Service("communityDynamicCommentService")
public class CommunityDynamicCommentServiceImpl implements CommunityDynamicCommentService {
    @Resource
    private CommunityDynamicCommentDao communityDynamicCommentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CommunityDynamicComment queryById(Integer id) {
        return this.communityDynamicCommentDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<CommunityDynamicComment> queryAllByLimit(int offset, int limit) {
        return this.communityDynamicCommentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param communityDynamicComment 实例对象
     * @return 实例对象
     */
    @Override
    public CommunityDynamicComment insert(CommunityDynamicComment communityDynamicComment) {
        this.communityDynamicCommentDao.insert(communityDynamicComment);
        return communityDynamicComment;
    }

    /**
     * 修改数据
     *
     * @param communityDynamicComment 实例对象
     * @return 实例对象
     */
    @Override
    public CommunityDynamicComment update(CommunityDynamicComment communityDynamicComment) {
        this.communityDynamicCommentDao.update(communityDynamicComment);
        return this.queryById(communityDynamicComment.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.communityDynamicCommentDao.deleteById(id) > 0;
    }
}